﻿using System;
using System.Threading;

namespace BToolkit
{
    public class MainThread
    {
        private static SynchronizationContext context;

        public static void InitOnMainThread()
        {
            context = SynchronizationContext.Current;
        }

        public static void Run(Action action)
        {
            context.Post(state =>
            {
                action?.Invoke();
            }, null);
        }
    }
}
